package com.ship.dispatch.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ship.common.core.web.domain.JsonResult;
import com.ship.common.log.annotation.Log;
import com.ship.common.log.enums.BusinessType;
import com.ship.dispatch.model.Vo.SpArrangeStatisticsVo;
import com.ship.dispatch.model.Vo.SpArrangeVo;
import com.ship.dispatch.model.dto.SpArrangeChartDto;
import com.ship.dispatch.model.dto.SpArrangePageDto;
import com.ship.dispatch.model.dto.SpArrangeStateUpdateDto;
import com.ship.dispatch.service.SpArrangeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 船货排布管理Controller111
 *
 * @author zhangyh
 * @create 2023/11/03
 */
@RestController
@RequestMapping("/spArrange" )
public class SpArrangeController {

    @Autowired
    private SpArrangeService spArrangeService;


    /**
     * 获取船货排布分页列表
     * @param pageDto
     * @return
     */
    @PostMapping("/page")
    public JsonResult<Page<SpArrangeVo>> page(@RequestBody SpArrangePageDto pageDto){
        Page page = new Page();
        page.setCurrent(pageDto.getPageNum());
        page.setSize(pageDto.getPageSize());
        page.setSearchCount(true);
        return spArrangeService.getPage(page, pageDto);
    }

    /**
     * 获取船货排布分页列表数据导出
     * @param pageDto
     * @return
     */
    @PostMapping("/page/export")
    public JsonResult pageExport(@RequestBody SpArrangePageDto pageDto){
//        ExportContractDataTask task = new ExportContractDataTask();
//        task.setBaseBean(conResourceMain);
//        task.setBaseService(conResourceMainService);
//        task.setMethodsName("page");
//        task.setModule(ModuleConst.CON_RESOURCE_MAIN);
//        task.setDownloadFileName("导出资源合同-主合同.zip");
//        task.setHttpRequestUtil(httpRequestUtil);
//        task.setSpringUtil(springUtil);
//        task.setUserId(Long.valueOf(SecurityUtils.getStringUserId()));
//        exportService.export(task);
        return JsonResult.success();
    }

    /**
     * 更新船货排布状态
     * @param dto
     * @return
     */
    @PostMapping("/state/update")
    @Log(title = "更新船货排布状态",businessType = BusinessType.UPDATE)
    public JsonResult<Long> stateUpdate(@RequestBody @Validated SpArrangeStateUpdateDto dto){
        return spArrangeService.stateUpdate(dto);
    }

    /**
     * 船货排布统计信息
     * @return
     */
//    @GetMapping("/top/statistics")
//    public JsonResult<SpArrangeStatisticsVo> topStatistics(){
//        return spArrangeService.topStatistics();
//    }

    /**
     * 船货排布甘特图信息
     * @return
     */
    @PostMapping("/chart")
    public JsonResult<SpArrangeVo> getChart(@RequestBody SpArrangeChartDto dto){
        return spArrangeService.getChart(dto);
    }

}
